import Cookies from 'js-cookie'
//js-cookies 教程 https://blog.csdn.net/qq_16828495/article/details/120783389
const state = {
  sidebar: {
    opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
    withoutAnimation: false
  },
  device: 'desktop',
  isCollapse: Cookies.get('collapse') 
}

const mutations = {
  
  collapseMenutest: () => {
    Cookies.set("collapse",'vuex里面设置的方法',{ expires: 7 }) 
    console.log("这是vuex的方法")
  }
}

const actions = {
  
  closeSideBar({ commit }, { withoutAnimation }) {
    commit('CLOSE_SIDEBAR', withoutAnimation)
  },
  toggleDevice({ commit }, device) {
    commit('TOGGLE_DEVICE', device)
  },
  setSize({ commit }, size) {
    commit('SET_SIZE', size)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
